Some programming languages are purely procedural, others are purely object-oriented, and some are a hybrid. In a procedural language, such as C, every call is a function call. In an object-oriented language, such as Java, every call is a method call. In a hybrid language, such as Perl, Javascript, or Forth, a call can be either a function call or a method call.
Suppose a software library is written in a hybrid language. The software library includes a plurality of library subroutines, which are written in a style such that they have to be called as functions. These functions can be defined in one class, but can be imported into another class. For example, in Perl, functions can be imported from one package into another package, where a package defines the boundary of a class. A user working with a package that imports a function may be unaware of whether the function is intended to be used as a function or as a method. If a user creates code that calls the imported function as a method, the code will be successfully compiled, but will produce undesirable behaviors at runtime.
Conventionally, a subroutine has two implementations, one implementation as a function and another implementation as a method, to allow a user to call the subroutine as either a function or a method. Alternatively, a user has to modify the existing code to ensure that the library subroutines are called as functions. Therefore, there is a need to improve software usability and flexibility, such that the above-mentioned problem can be overcome.